import React from 'react'

import { Rate } from 'antd';

import ItemSty from '../../css/movieitem.module.scss'

export default class MovieItem extends React.Component {
    constructor(props){
        super(props)
        this.state = {}
    }

    render() {
        return (
            <div className={ItemSty.box} onClick={this.goDetail}>
                <img src={this.props.images.small.replace('img3.doubanio.com','img1.doubanio.com'||'img3.doubanio.com')} className={ItemSty.img} alt=""/>
                <h4>{this.props.title}</h4>
                <h4>{this.props.year}</h4>
                <h4>{this.props.genres.join(' ')}</h4>
                <Rate disabled defaultValue={this.props.rating.average/2} />
            </div>
        )
    }

    goDetail = () => {
        this.props.history.push('/movie/detail/'+this.props.id)
    }
}